import { createRouter, createWebHistory } from 'vue-router'
import StudentSignIn from '../views/StudentSignIn.vue'
import TeacherControlPanel from '../views/TeacherControlPanel.vue'
import HistoricalSignInView from '../views/HistoricalSignInView.vue'

const routes = [
  {
    path: '/',
    name: 'StudentSignIn',
    component: StudentSignIn,
    meta: {
      title: '学生签到'
    }
  },
  {
    path: '/teacher',
    name: 'TeacherControlPanel',
    component: TeacherControlPanel,
    meta: {
      title: '教师控制面板'
    }
  },
  {
    path: '/teacher/history',
    name: 'HistoricalSignIn',
    component: HistoricalSignInView,
    meta: {
      title: '历史签到查询'
    }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title + ' - 微机室签到系统'
  }
  next()
})

export default router